package com.lw.dao;

import com.lw.pojo.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

/**
 * @author LW
 * @2020/10/3 14:41
 */
public class UserDaoImpl extends SqlSessionDaoSupport implements UserDao {
    public List<User> queryAll() {
        User user = new User(3, "ll", "123");
        UserDao mapper = getSqlSession().getMapper(UserDao.class);
        mapper.addUser(user);
        mapper.deleteUser(2);
//        getSqlSession()就可以得到 一个Template
        return mapper.queryAll();
    }

    public int addUser(User user) {
        int i = getSqlSession().getMapper(UserDao.class).addUser(user);
        return i;
    }

    public int deleteUser(int id) {
        int i = getSqlSession().getMapper(UserDao.class).deleteUser(id);
        return i;
    }
}
